package jp.jig.test.alarm;

import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

import com.google.android.gcm.GCMBaseIntentService;

// GCM Sender ID: 991332016232

// GCM API key: AIzaSyBz3CHr_unT3QlqKFPkWxUKqHQkLafgfH0

public class GCMIntentService extends GCMBaseIntentService {



	// user (ユーザー名), rid (RegistrationID) をポスト


	public GCMIntentService() {
		super(AlarmService.SENDER_ID);
	}

	@Override
	public void onRegistered(Context context, String registrationId) {
		Log.w("registration id:", registrationId);
		AlarmService.postRID(context, registrationId);
	}

	@Override
	protected void onUnregistered(Context context, String registrationId) {
		// sendMessage("C2DM Unregistered");
		System.out.println("onUnregistered:" + registrationId);
	}

	@Override
	public void onError(Context context, String errorId) {
		System.out.println("onError:" + errorId);
		// sendMessage("err:" + errorId);
	}

	@Override
	protected void onMessage(Context context, Intent intent) {
		String str = intent.getStringExtra("message");
		System.out.println("[プッシュ通知]" + str);
		AlarmService.sendMessage(context, str);
	}



}
